{
GdkWindow *window;
- if (GTK_IS_TREE_VIEW (widget))
- window = gtk_tree_view_get_bin_window (GTK_TREE_VIEW (widget));
- else
- window = gtk_widget_get_window (widget);
-
+ window = gtk_widget_get_window (widget);
gdk_window_get_origin (window, x_window, y_window);
window = gdk_window_get_toplevel (gtk_widget_get_window (widget));
gdk_window_get_origin (window, x_toplevel, y_toplevel);
+
+ if (GTK_IS_TREE_VIEW (widget))
+ {
+ gtk_tree_view_convert_widget_to_bin_window_coords (GTK_TREE_VIEW (widget),
+ *x_window, *y_window,
+ x_window, y_window);
+ gtk_tree_view_convert_widget_to_bin_window_coords (GTK_TREE_VIEW (widget),
+ *x_toplevel, *y_toplevel,
+ x_toplevel, y_toplevel);
+ }
}
static void
{
GtkWidget *widget;
GtkTreeView *tree_view;
- GdkWindow *bin_window;
GdkRectangle cell_rect;
gint w_x, w_y;
tree_view = GTK_TREE_VIEW (widget);
gtk_tree_view_accessible_get_cell_area (parent, cell, &cell_rect);
- bin_window = gtk_tree_view_get_bin_window (tree_view);
- gdk_window_get_origin (bin_window, &w_x, &w_y);
+ gtk_tree_view_convert_widget_to_bin_window_coords (tree_view,
+ 0, 0,
+ &w_x, &w_y);
- if (coord_type == ATK_XY_WINDOW)
+ if (coord_type != ATK_XY_WINDOW)
{
GdkWindow *window;
gint x_toplevel, y_toplevel;
- window = gdk_window_get_toplevel (bin_window);
+ window = gdk_window_get_toplevel (gtk_widget_get_window (widget));
gdk_window_get_origin (window, &x_toplevel, &y_toplevel);
- w_x -= x_toplevel;
- w_y -= y_toplevel;
+ w_x += x_toplevel;
+ w_y += y_toplevel;
}
*width = cell_rect.width;
}
}
-/**
- * gtk_tree_view_get_bin_window:
- * @tree_view: A #GtkTreeView
- *
- * Returns the window that @tree_view renders to.
- * This is used primarily to compare to `event->window`
- * to confirm that the event on @tree_view is on the right window.
- *
- * Returns: (nullable) (transfer none): A #GdkWindow, or %NULL when @tree_view
- * hasn’t been realized yet.
- **/
-GdkWindow *
-gtk_tree_view_get_bin_window (GtkTreeView *tree_view)
-{
- g_return_val_if_fail (GTK_IS_TREE_VIEW (tree_view), NULL);
-
- return tree_view->priv->bin_window;
-}
-
/**
* gtk_tree_view_get_path_at_pos:
* @tree_view: A #GtkTreeView.
* @cell_y: (out) (optional): A pointer where the Y coordinate
* relative to the cell can be placed, or %NULL
*
- * Finds the path at the point (@x, @y), relative to bin_window coordinates
- * (please see gtk_tree_view_get_bin_window()).
- * That is, @x and @y are relative to an events coordinates. @x and @y must
- * come from an event on the @tree_view only where `event->window ==
- * gtk_tree_view_get_bin_window ()`. It is primarily for
+ * Finds the path at the point (@x, @y), relative to bin_window coordinates.
+ * That is, @x and @y are relative to an events coordinates. Widget-relative
+ * coordinates must be converted using
+ * gtk_tree_view_convert_widget_to_bin_window_coords(). It is primarily for
* things like popup menus. If @path is non-%NULL, then it will be filled
* with the #GtkTreePath at that point. This path should be freed with
* gtk_tree_path_free(). If @column is non-%NULL, then it will be filled
* @bx: (out): return location for bin_window X coordinate
* @by: (out): return location for bin_window Y coordinate
*
- * Converts widget coordinates to coordinates for the bin_window
- * (see gtk_tree_view_get_bin_window()).
+ * Converts widget coordinates to coordinates for the bin_window.
*
* Since: 2.12
**/
* @wx: (out): return location for widget X coordinate
* @wy: (out): return location for widget Y coordinate
*
- * Converts bin_window coordinates (see gtk_tree_view_get_bin_window())
- * to widget relative coordinates.
+ * Converts bin_window coordinates to widget relative coordinates.
*
* Since: 2.12
**/
* selection, having a custom context menu or starting rubber banding.
*
* The @x and @y coordinate that are provided must be relative to bin_window
- * coordinates. That is, @x and @y must come from an event on @tree_view
- * where `event->window == gtk_tree_view_get_bin_window ()`.
+ * coordinates. Widget-relative coordinates must be converted using
+ * gtk_tree_view_convert_widget_to_bin_window_coords().
*
* For converting widget coordinates (eg. the ones you get from
* GtkWidget::query-tooltip), please see
button_press_event (GtkWidget *widget, GdkEventButton *event, gpointer callback_data)
{
/* Deselect if people click outside any row. */
- if (event->window == gtk_tree_view_get_bin_window (GTK_TREE_VIEW (widget))
- && !gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (widget),
- event->x, event->y, NULL, NULL, NULL, NULL)) {
+ if (!gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (widget),
+ event->x, event->y, NULL, NULL, NULL, NULL)) {
gtk_tree_selection_unselect_all (gtk_tree_view_get_selection (GTK_TREE_VIEW (widget)));
}